package cn.well.cloud.quartz.core.factory;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cn.well.cloud.quartz.core.model.ScheduleJob;
import cn.well.cloud.quartz.core.task.TaskUtils;

/**
 * 
 * @Description: 若一个方法一次执行不完下次轮转时则等待改方法执行完后才执行下一次操作
 * @author wison
 * @date 2017年11月11日 下午5:05:47
 */
@DisallowConcurrentExecution
@Component
public class QuartzJobFactoryDisallowConcurrentExecution implements Job {
  private final Logger log = LoggerFactory.getLogger(this.getClass());
  @Autowired
  private TaskUtils taskUtils;
  
  public void execute(JobExecutionContext context) throws JobExecutionException {
      ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get("scheduleJob");
      taskUtils.invokMethod(scheduleJob);

  }
}